package com.ll.aync;

import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class CustomEventListener implements ApplicationListener<CustomEvent> {

	@Async
	@Override
	public void onApplicationEvent(CustomEvent event) {
		CustomEvent.buildLocal(" 100000001  ");
		System.out.println( Thread.currentThread().getName() +  "  CustomEvent action" );

		try {
			Thread.sleep(1000L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		System.out.println(Thread.currentThread().getName() +  " custom finish: " + CustomEvent.getLocal());
		event.count.countDown();
	}
}
